<template>
	<view class="h-100">
		<block v-if="!isHaveGood">
		 <view class="pad-10">
		 	<view class="d-flex mb-2 a-center" v-for="(item,index) in goodList" :key="index" >
				<view class="w-15 d-flex a-center j-center">
					<u-checkbox-group>
					<u-checkbox  activeColor="red" :checked="item.checked" @change=""></u-checkbox>
					</u-checkbox-group>
				</view>
		 		<image class="w-25" :src="item.goodImg" mode="widthFix" @tap="goToGoodDetail"></image>
				<view class="ml-2 w-50">
					<view class="">{{item.goodName}}</view>
					<view class="font-40  mt-2 d-flex a-center j-sb">
						<text class="fc-3">￥{{item.goodPrice}}</text>
						<view class="">
							<text class="bg-black2 pad-20">-</text>
							<text class="ml-2 mr-2">{{goodNum}}</text>
							<text class="bg-black2 pad-20">+</text>
						</view>
					</view>
				</view>
		 	</view>
		 </view>
		 <view class="h-bar p-fixed left-0  w-100  d-flex a-center j-sb  border-box" style="bottom: 50px;padding-left: 10px;border-top: 1upx solid #ddd;"> 
		 <u-checkbox-group>
		 <u-checkbox  activeColor="red" :checked="allChecked" @change="" label="全选" ></u-checkbox>
		 </u-checkbox-group>
						 <view class="">
						 	合计<text class="fc-red1">￥54</text>
						 </view>
						 <view class="bg-4 h-100 t-center px-4 w-33 fc font-35" style="line-height: 50px;" @tap="goToPay">
						 	结算
						 </view>
		 </view>
		 <view class="h-bar"> </view>
		</block>
		<block v-if="isHaveGood">
			<view class="h-100 d-flex j-center a-center">
				<u-empty
				        mode="car"
				        icon="http://cdn.uviewui.com/uview/empty/car.png"
				>
				<button type="primary" plain @tap="ToByGoods">去逛逛</button>
				</u-empty>
			</view>
		</block>
		
	</view>
</template>

<script>
	import {getGoodList,setGoodListStorage} from '../../utils/tools.js'
	export default {
		data() {
			return {
				goodList:[],
				isHaveGood:true,
				checked:false,
				goodNum:1,
				allChecked:false
			};
		},
		methods: {
			
			
			// 跳转到支付页面
			goToPay(){
				uni.navigateTo({
						url:'/pages/payPage/payPage'		
				})
			},
			// 点击商品跳转到详情页面
			goToGoodDetail(){
				uni.navigateTo({
					url:'/pages/goodDetails/goodDetails'
				})
			},
			ToByGoods() {
				uni.reLaunch({
					url:'/pages/goodsList/index'
				})
			}
		},
		onShow() {
			console.log("g-onShow");
			let goodArr = getGoodList();
			console.log(goodArr);
			if(goodArr.length==0){
				this.isHaveGood = true
			}else{
				this.isHaveGood = false
				this.goodList = goodArr
			}
		},
		
	}
</script>

<style lang="scss">

</style>
